package com.wf.smartcomm.server.filter;

import com.wf.smartcomm.server.util.StringUtil;

/** 
 * @author 38884306@qq.com  
 * @version 创建时间：2015-5-28 下午4:57:47 
 * 
 */
public class HtmlFilter {
	
	public static String genderFilter(String gender){
		if (!StringUtil.isEmpty(gender)) {
			if (gender.equals("1")) {
				return "男";
			}else {
				return "女";
			}
		}else {
			return null;
		}
	}
	
	public static String filter(String message) {

        if (message == null)
            return (null);

        char content[] = new char[message.length()];
        message.getChars(0, message.length(), content, 0);
        StringBuffer result = new StringBuffer(content.length + 50);
        for (int i = 0; i < content.length; i++) {
            switch (content[i]) {
            case '<':
                result.append("&lt;");
                break;
            case '>':
                result.append("&gt;");
                break;
            case '&':
                result.append("&amp;");
                break;
            case '"':
                result.append("&quot;");
                break;
            default:
                result.append(content[i]);
            }
        }
        return (result.toString());

    }
}
